﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BlockeyEssentials.ScreenSystem.ScreenTypes
{
    public class SplashScreen : Screen
    {
        public SplashScreen(ScreenManager oManager, float oTime)
            : base(oManager)
        {
            _TimeToStayAlive = oTime;
            TransitionRate = (1f / 60f) * 0.75f;
        }

        #region Methods

        public override void Update()
        {
            if (Active)
            {
                if (Alive)
                    _Timer += (float)All.GameTime.ElapsedGameTime.TotalSeconds;
            }
        }

        public override void Draw(SpriteBatch oSB)
        {
            Vector2 oCenter = new Vector2(All.Resolution.Center.X, All.Resolution.Center.Y);
            Vector2 oOrigin = new Vector2(Texture.Width / 2, Texture.Height / 2);

            oSB.Draw(Texture, oCenter, null, SplashColor, 0.0f, oOrigin, 1.0f, SpriteEffects.None, 1.0f);
        }

        #endregion

        #region Properties

        public Texture2D Texture
        {
            get { return _Texture; }
            set { _Texture = value; }
        }

        public bool Alive
        {
            get { return _Timer < _TimeToStayAlive; }
        }

        public bool Dead
        {
            get { return Alive == false; }
        }

        public Color SplashColor
        {
            get { return _Color; }
            set { _Color = value; }
        }

        #endregion

        float _Timer;
        float _TimeToStayAlive;
        Texture2D _Texture;
        Color _Color;
    }
}
